<template>
  <h1>我是App组件</h1>
  <h2>一个人的信息</h2>
  <h3>姓名:{{ name }}</h3>
  <h3>年龄:{{ age }}</h3>
  <h3>工作种类:{{ job.type }}</h3>
  <h3>工作薪水:{{ job.salary }}</h3>
  <button @click="changeInfo">修改个人信息</button>
</template>

<script>
import { ref } from 'vue'
export default {
  name: 'App',
  setup() {
    // 数据
    let name = ref('王某')
    let age = ref(18)
    let job = ref({
      type: '前端工程师',
      salary: '30k',
    })
    let test = ref({
      test1: {
        test3: '第二层',
        test4: {
          tset5: '第五层',
        },
      },
      test2: '第一层',
    })

    // 方法
    function changeInfo() {
      // name.value = '王总'
      // age.value = 23
      job.value.type = 'UI'
      job.value.salary = '60k'
      console.log(job.value)
      console.log(test.value.test1)
    }

    // 返回一个对象(常用)
    return {
      name,
      age,
      job,
      changeInfo,
    }
  },
}
</script>
